package com.icecola.d7_thread_communication;

public class ThreadTest {
    public static void main(String[] args) {
        //需求： 3个生产者线程，负责生产包子，每个线程每次只能生产1个包子放在桌子上
        // 2个消费者线程负责吃包子，每人每次只能拿1个包子吃
        // 5个线程，1个桌子对象
        Desk desk = new Desk();
        new Thread(()->{
            while (true){
                desk.put();
            }
        },"厨师一").start();
        new Thread(()->{
            while (true){
                desk.put();
            }
        },"厨师二").start();
        new Thread(()->{
            while (true){
                desk.put();
            }
        },"厨师三").start();
        new Thread(()->{
            while (true){
                desk.get();
            }
        },"吃货1").start();
        new Thread(()->{
            while (true){
                desk.get();
            }
        },"吃货2").start();
    }
}
